<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>KEY_EVENT_RECORD</title>
<meta http-equiv="Content-Type" Content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="../../styles/styles.css">
<script language="javascript" src="../links.js" type="text/javascript"></script>
</head>

<body>

<h1>KEY_EVENT_RECORD</h1>
<div class=navbar>
<a href="../index.html">main</a> |
<a href="../structures/index.html">structures</a> |
<a href="index.html">win32 structures</a> |
<a href="input_record.html">INPUT_RECORD</a>
</div>

<div class=shortdescr>
The <dfn>KEY_EVENT_RECORD</dfn> structure is used to report keyboard input events in a console <dfn>INPUT_RECORD</dfn> structure.
</div>

<pre class=syntax>
typedef struct _KEY_EVENT_RECORD {
    BOOL bKeyDown;
    WORD wRepeatCount;
    WORD wVirtualKeyCode;
    WORD wVirtualScanCode;
    union {
        WCHAR UnicodeChar;
        CHAR  AsciiChar;
    } uChar;
    DWORD dwControlKeyState;
} KEY_EVENT_RECORD;
</pre>

<h3>Members</h3>
<div class=descr>
    <div class=dfn>bKeyDown</div>
    <div class=dfndescr>Indicates whether a key is down. This member is TRUE if the key is pressed, or FALSE if the key is released.</div>
    <div class=dfn>wRepeatCount</div>
    <div class=dfndescr>Count indicating that a key is being held down. For example, when a key
       is held down, you might get five events with this member equal to 1, one event with this
       member equal to 5, or multiple events with this member greater than or equal to 1.</div>
    <div class=dfn>wVirtualKeyCode</div>
    <div class=dfndescr><a href="virtualkeycodes.html">Virtual-key code</a> that identifies the
       given key in a device-independent manner.</div>
    <div class=dfn>wVirtualScanCode</div>
    <div class=dfndescr>Virtual scan code of the given key that represents the device-dependent
       value generated by the keyboard hardware.</div>
    <div class=dfn>uChar</div>
    <div class=dfndescr>Translated Unicode or ASCII character, depending on whether the
       wide-character (Unicode) or ANSI version of the <a href="readconsoleinput.html">ReadConsoleInput</a>
       function was used.</div>
    <div class=dfn>dwControlKeyState</div>
    <div class=dfndescr>Indicates the state of the control keys. This member can be one or more of the following values.

     <table class="cont">
     <tr class="cont"><th class="cont" width="20%">Key</th><th class="cont" width="20%">Value</th><th class="cont" width="60%">Description</th></tr>
        <tr class="cont"><td class="cont" width="20%">CAPSLOCK_ON</td><td class="cont" width="20%">0x0080</td>
        <td class="cont" width="60%">The CAPS LOCK light is on.</td>
        </tr>
        <tr class="cont"><td class="cont" width="20%">ENHANCED_KEY</td><td class="cont" width="20%">0x0100</td>
        <td class="cont" width="60%">The key is enhanced.</td>
        </tr>
        <tr class="cont"><td class="cont" width="20%">LEFT_ALT_PRESSED </td><td class="cont" width="20%">0x0002</td>
        <td class="cont" width="60%">The left ALT key is pressed.</td>
        </tr>
        <tr class="cont"><td class="cont" width="20%">LEFT_CTRL_PRESSED </td><td class="cont" width="20%">0x0008</td>
        <td class="cont" width="60%">The left CTRL key is pressed.</td>
        </tr>
        <tr class="cont"><td class="cont" width="20%">NUMLOCK_ON </td><td class="cont" width="20%">0x0020</td>
        <td class="cont" width="60%">The NUM LOCK light is on.</td>
        </tr>
        <tr class="cont"><td class="cont" width="20%">RIGHT_ALT_PRESSED </td><td class="cont" width="20%">0x0001</td>
        <td class="cont" width="60%">The right ALT key is pressed.</td>
        </tr>
        <tr class="cont"><td class="cont" width="20%">RIGHT_CTRL_PRESSED </td><td class="cont" width="20%">0x0004</td>
        <td class="cont" width="60%">The right CTRL key is pressed.</td>
        </tr>
        <tr class="cont"><td class="cont" width="20%">SCROLLLOCK_ON </td><td class="cont" width="20%">0x0040</td>
        <td class="cont" width="60%">The SCROLL LOCK light is on.</td>
        </tr>
        <tr class="cont"><td class="cont" width="20%">SHIFT_PRESSED </td><td class="cont" width="20%">0x0010</td>
        <td class="cont" width="60%">The SHIFT key is pressed.</td>
        </tr>
     </table>
    </div>
</div>

<h3>Remarks</h3>
<div class=descr>
  Enhanced keys for the IBM<sup>&#174;</sup> 101- and 102-key keyboards are the INS, DEL,
  HOME, END, PAGE UP, PAGE DOWN, and direction keys in the clusters to the left of the keypad;
  and the divide (<code>/</code>) and ENTER keys in the keypad.
  <br>
  Keyboard input events are generated when any key, including control keys, is pressed or
  released. However, the ALT key when pressed and released without combining with another
  character, has special meaning to the system and is not passed through to the application.
  Also, the <code>CTRL+C</code> key combination is not passed through if the input handle is
  in processed mode (ENABLE_PROCESSED_INPUT).
</div>

<div class=see>See also:</div><div class=seecont>
<a href="peekconsoleinput.html">PeekConsoleInput</a>,
<a href="readconsoleinput.html">ReadConsoleInput</a>,
<a href="writeconsoleinput.html">WriteConsoleInput</a>,
<a href="input_record.html">INPUT_RECORD</a>
</div>

</body>
</html>